<?php
if (isset($_SESSION['admin-login'])) {
	header("Location: ".site()."/".$param[0]."/menu");
} else {
	if (isset($_POST['login'])) {
		$username = amankan($_POST['username']);
		$password = md5($_POST['password']);
		$redir = site()."/".$param[0];
		$check_login = db_result("SELECT * FROM user WHERE username = '$username' AND password = '$password'");
		if ($check_login == false) {
			$_SESSION['status-login'] = "Username atau Password salah";
			$redir .= "/login";
		} else {
			$_SESSION['admin-login'] = $username;
			$redir .= "/menu";
		}
		header('Location: '.$redir);
	}
}
?>